'''
类的继承
(1)类继承object
(2)str.format():{数字序列:对其说明<>^、最小长度}
(3)内置属性__base__
'''

#父类（基类）
class Student:

    #公共属性
    @property
    def area(self):
        area = "ShangHai"
        return area

    #构造函数
    def __init__(self,id,name):
        self.id = id
        self.name = name

    #方法
    def study(self):
        string = "area:{0:<10} id:{1:<10} name:{2:<6}"
        string = string.format(self.area,self.id,self.name)
        print(string)

#子类（派生类）
class ColleageStudent(Student):
    #构造函数
    def __init__(self,id,name,colleagName):
        Student.__init__(self,id,name)
        self.colleagName = colleagName #子类属性

    def study(self):
        string = "area:{0:<10} colleage:{1:<10} id:{2:<10} name:{3:<6}"
        string = string.format(self.area,self.colleagName,self.id,self.name)
        print(string)

#子类(派生类)
class DeptStudent(ColleageStudent):
    #构造函数
    def __init__(self,id,name,colleagName,deptName):
        ColleageStudent.__init__(self,id,name,colleagName)
        self.deptName = deptName #子类属性

    def study(self):
        string = "area:{0:<10} colleage:{1:<10} id:{2:<10} name:{3:<6} dept:{4}"
        string = string.format(self.area,self.colleagName,self.id,self.name,self.deptName)
        print(string)

#主程序
#父类对象创建
stu = Student("230001","Lily")
stu.study()
print(Student.__bases__)

#子类对象创建
stuSD = ColleageStudent("230002","Lily","Sandau")
stuSD.study()
print(ColleageStudent.__bases__)

#子类对象创建
stuIS = DeptStudent("230003","John","Sandau","IS")
stuIS.study()
print(DeptStudent.__bases__)
